package guava;

import com.google.common.base.CharMatcher;

/**
 * 将字符的匹配和处理解耦，并提供丰富的方法
 *
 * @author Daniel
 */
public class CharMatcherTest {

    /**
     * 数字提取器，会处理unicode码
     */
    private static final CharMatcher CHAR_MATCHER_DIGIT1 = CharMatcher.digit();

    /**
     * 数字提取器，只会处理ASCII数字
     */
    private static final CharMatcher CHAR_MATCHER_DIGIT2 = CharMatcher.inRange('0', '9');

    public static void main(String[] args) {
        String data = "abc2dmf134f>";
        String digit1 = CHAR_MATCHER_DIGIT1.retainFrom(data);
        System.out.println("digit1 = " + digit1);

        String digit2 = CHAR_MATCHER_DIGIT2.retainFrom(data);
        System.out.println("digit2 = " + digit2);
    }


}
